//
// GNS_ServiceLayer.cpp
// GameHall
//
// Created by mr.l on 16/2/3.
//
//

#include "GNS_ServiceLayer.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
#include "GNS_PlayerMgr.h"
USING_NS_CC;
using namespace cocostudio::timeline;
using namespace ui;

#define winsize Director::getInstance()->getVisibleSize()

GNS_ServiceLayer::GNS_ServiceLayer()
{

}

GNS_ServiceLayer::~GNS_ServiceLayer()
{
    
}

GNS_ServiceLayer* GNS_ServiceLayer::createLayer()
{
    auto pGNS_ServiceLayer = GNS_ServiceLayer::create();
    auto pScene = Director::getInstance()->getRunningScene();
    if (!pScene)
        return 0;
    pScene->addChild(pGNS_ServiceLayer);
    return pGNS_ServiceLayer;
}

bool GNS_ServiceLayer::init()
{
    if ( !GNS_YJFLayer::init() )
    {
        return false;
    }
    return true;
}
void GNS_ServiceLayer::SetNodeName(std::string CsbName)
{
	m_RootNode = Loadcsb(CsbName);
	addChild(m_RootNode, 11);

	auto pBackBtn = static_cast<Button*>(m_RootNode->getChildByName("Button_4"));
    pBackBtn->setTag(1);
    pBackBtn->addTouchEventListener(CC_CALLBACK_2(GNS_ServiceLayer::BtnCallBack, this));
    
	auto qqText = static_cast<Text*>(m_RootNode->getChildByName("Text_2"));
	qqText->setString(GTOU(GNS_PlayerMgr::GetInstance()->GetContactInfo()->szQQ));

	auto webText = static_cast<Text*>(m_RootNode->getChildByName("Text_2_0"));
	webText->setString(GTOU(GNS_PlayerMgr::GetInstance()->GetContactInfo()->szWebSite));

	auto phoneText = static_cast<Text*>(m_RootNode->getChildByName("Text_4"));
	phoneText->setString(GTOU(GNS_PlayerMgr::GetInstance()->GetContactInfo()->szTelephone));
    
}
void GNS_ServiceLayer::BtnCallBack(cocos2d::Ref *pSender, ui::Widget::TouchEventType type){
    if (type==ui::Widget::TouchEventType::ENDED) {
        auto pButton = (Button*)pSender;
        int BtnTag = pButton->getTag();
        switch (BtnTag) {
            case 1:
            {
					  Show(false);

                break;
            }
            default:
                break;
        }
    }
}
